package unit9_1;

public class Dog {
    private String name;//私有属性 不能直接被外部访问
    private int age;
    private String color;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge(String uID,int upwd) {
        if(uID=="aaa"&&upwd==123){
            return age;
        }else{
            return 0;
        }

    }

    public void setAge(int age) {
        if(age>20||age<0){
            System.out.println("输入不合法");
        }else{
            this.age = age;
        }
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }



//    公有方法
    public void eat(){
        System.out.println("狗子吃饭");
        System.out.println("3min~");
        System.out.println("狗子吃完饭");
        this.play();
    }
//    私有方法
    private void play(){
        System.out.println("狗🐕玩飞盘，打王者~~");
    }
}

